package com.txh.blog.service.impl;

import com.txh.blog.mapper.UserInfoMapper;
import com.txh.blog.model.UserInfo;
import com.txh.blog.service.UserInfoService;
import com.txh.blog.util.PassWordHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserInfoServiceImpl implements UserInfoService {

    @Autowired
    UserInfoMapper userInfoMapper;
    @Override
    public boolean findUser(UserInfo userInfo) {
        UserInfo user = userInfoMapper.findUserInfoByName(userInfo.getUserName());
        if (user == null){
            return false;
        }else{
            if (user.getPassWord().equals(PassWordHelper.Sha256Encoding(userInfo.getPassWord()+user.getSalt()))){
                return true;
            }else{
                return false;
            }
        }
    }
}
